package com.estar.integaration.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.estar.integaration.Mapper.MaterialVoMapper;
import com.estar.integaration.Service.IMaterialVoService;
import com.estar.integaration.entity.Material;
import com.estar.integaration.entity.MaterialVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author YJL
 * @since 2021-11-20
 */
@Service
public class MaterialVoServiceImpl extends ServiceImpl<MaterialVoMapper, MaterialVo> implements IMaterialVoService {

  @Autowired
  MaterialVoMapper materialvoMapper;

  @Override
  public List<MaterialVo> getMaterialVOList(QueryWrapper queryWrapper) {
    return  materialvoMapper.selectList(queryWrapper);
  }

  public void deleteById(List<MaterialVo> materialvoList){

    List<String> idList = new ArrayList<>();

    materialvoList.forEach(m -> idList.add(m.getId()));

    materialvoMapper.deleteBatchIds(idList);

  }

  /**
   * 功能： 根据product_id拿到无交期的物料
   * @param productId
   * @return
   */
  @Override
  public List<MaterialVo> getMaterialByProductId(String productId) {

    QueryWrapper queryWrapper = new QueryWrapper();
    queryWrapper.eq("product_id",productId);
    return materialvoMapper.selectList(queryWrapper);

  }


}
